package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysXq;
import com.ruoyi.system.service.ISysXqService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 需求管理Controller
 * 
 * @author ruoyi
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/system/xq")
public class SysXqController extends BaseController
{
    @Autowired
    private ISysXqService sysXqService;

    /**
     * 查询需求管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:xq:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysXq sysXq)
    {
        startPage();
        List<SysXq> list = sysXqService.selectSysXqList(sysXq);
        return getDataTable(list);
    }


    @GetMapping("/app/list")
    public TableDataInfo applist(SysXq sysXq)
    {
        startPage();
        List<SysXq> list = sysXqService.selectSysXqList(sysXq);
        return getDataTable(list);
    }
    
    /**
     * 导出需求管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:xq:export')")
    @Log(title = "需求管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysXq sysXq)
    {
        List<SysXq> list = sysXqService.selectSysXqList(sysXq);
        ExcelUtil<SysXq> util = new ExcelUtil<SysXq>(SysXq.class);
        util.exportExcel(response, list, "需求管理数据");
    }

    /**
     * 获取需求管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:xq:query')")
    @GetMapping(value = "/{xqid}")
    public AjaxResult getInfo(@PathVariable("xqid") Long xqid)
    {
        return success(sysXqService.selectSysXqByXqid(xqid));
    }

    
    @GetMapping(value = "app/{xqid}")
    public AjaxResult getappInfo(@PathVariable("xqid") Long xqid)
    {
        return success(sysXqService.selectSysXqByXqid(xqid));
    }
    /**
     * 新增需求管理
     */
    @PreAuthorize("@ss.hasPermi('system:xq:add')")
    @Log(title = "需求管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysXq sysXq)
    {
        return toAjax(sysXqService.insertSysXq(sysXq));
    }

    /**
     * 修改需求管理
     */
    @PreAuthorize("@ss.hasPermi('system:xq:edit')")
    @Log(title = "需求管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysXq sysXq)
    {
        return toAjax(sysXqService.updateSysXq(sysXq));
    }

    /**
     * 删除需求管理
     */
    @PreAuthorize("@ss.hasPermi('system:xq:remove')")
    @Log(title = "需求管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{xqids}")
    public AjaxResult remove(@PathVariable Long[] xqids)
    {
        return toAjax(sysXqService.deleteSysXqByXqids(xqids));
    }
}
